<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>添加产品类型</title>
    <script type="text/javascript">
      Ext.onReady(function(){        
        var name = new Ext.form.TextField({
          fieldLabel: '名称',
          allowBlank: false,
          blankText: "产品类型名称不能为空",
          name: 'name',
          anchor: '95%'
        });
        
        var desc = new Ext.form.TextArea({
          fieldLabel: '描述',
          name: 'description',
          height:105,
          anchor: '95%'
        });

        //提交按钮
        var submitButton = new Ext.Button({
          text: '提交',
          iconCls: 'icon-save',
          handler: function(){
            submitButton.setDisabled(true);
            if (newBrandForm.form.isValid()) {
              newBrandForm.form.submit({
                method: 'GET',
                success: function(result, response){
                  if (response.result.info == "成功") {
                    //添加成功后，隐藏窗口，并刷新Grid
                    newProductTypeWin.destroy();
                  }
                  else {
                    Ext.MessageBox.alert('消息', response.result.info);
                  }
                },
                failure: function(result, response){
                  Ext.MessageBox.alert('提示', result.responseText);
                }
              });
            }
            else {
              submitButton.enable();              
            }
          }
        })

        //暂时保存按钮
        var closeButton = new Ext.Button({
          text: '关闭',
          tooltip: '关闭当前窗口，并且当前编辑的信息不能保存。',
          iconCls: 'exit',
          handler: function(){
            newProductTypeWin.destroy();
          }
        });
        
        var newBrandForm = new Ext.FormPanel({
          labelWidth: 55, // label settings here cascade unless overridden
          url:'/product_type/create',
          frame:true,
          //title: '添加产品类型',
          bodyStyle:'padding:5px 5px 0',
          width: 310,
          //height:300,
          items: [name,desc],
          buttons:[submitButton,closeButton]
        });
        newBrandForm.render('new_product_type_form');
      })
    </script>
  </head>
  <body>
    <div id="new_product_type_form"></div>
  </body>
</html>
